/**
 * @Author: colpu
 * @Date: 2025-03-29 17:57:34
 * @LastEditors: colpu ycg520520@qq.com
 * @LastEditTime: 2025-04-04 12:28:14
 * @
 * @Copyright (c) 2025 by colpu, All Rights Reserved.
 */
import shell from 'shelljs'; // 脚本执行

/**
 * @function deploy 执行命令方法
 * @param {String} env 环境变量
 * @param {String} argv bash 参数
 * @description 本地开发
 */
export default async function deploy(env, argv) {
  process.env.NODE_ENV = env;
  if (!shell.which('pm2')) {
    // 在控制台输出内容
    shell.echo('抱歉没有安装pm2');
    shell.exit(1);
  } else {
    const bash = `pm2 deploy launched.config.mjs ${env} ${argv}`;
    shell.echo(bash);
    shell.exec(bash);
  }
};
